﻿using Gfw.Repositories.Manage;
using Gfw.Web.Models.Manage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gfw.BLL.Basic.Manage
{
    /// <summary>
    /// 统计
    /// </summary>
    public class StatisticsLogic
    {
        #region 总利润表

        /// <summary>
        /// 按时间统计公司利润
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalSize"></param>
        /// <returns></returns>
        public static IList<ProfitStatisticsModel> ProfitQuery(DateTime? start, DateTime? end, int pageIndex, int pageSize, out int totalSize)
        {
            ActCompanyStatisticsprofitRepository repository = new ActCompanyStatisticsprofitRepository();
            var hs = repository.Query(start, end, pageIndex - 1, pageSize, out totalSize);
            var models = new List<ProfitStatisticsModel>();

            foreach (var h in hs)
            {
                ProfitStatisticsModel m = h.CopyTo<ProfitStatisticsModel>();
                m.SettlementDate = h.SettlementDate.ToString();

                models.Add(m);
            }

            return models;
        }

        #endregion
    }
}
